package com.ll.module_translate.utils

import com.fenghuajueli.libbasecoreui.utils.MmkvUtils

/**
 * @Author: ll
 * @CreateTime: 2021/10/29 10:32
 */
object TransLanguage {
    const val AUTO = "auto"
    const val RUSSIAN = "ru"
    const val ENGLISH = "en"
    const val CHINESE = "zh"

    val CToR = CHINESE to RUSSIAN
    val RToC = RUSSIAN to CHINESE



    fun saveFrom(fromCN: String, from: String) {
        MmkvUtils.save(TRANS_FROM_CHINA_KEY, fromCN)
        MmkvUtils.save(TRANS_FROM_KEY, from)
    }

    fun saveTo(toCN: String, to: String) {
        MmkvUtils.save(TRANS_TO_CHINA_KEY, toCN)
        MmkvUtils.save(TRANS_TO_KEY, to)
    }

    private fun getFromCN(): String {
        return MmkvUtils.get(TRANS_FROM_CHINA_KEY, "自动检测")
    }

    private fun getFrom(): String {
        return MmkvUtils.get(TRANS_FROM_KEY, "auto")
    }

    private fun getToCN(): String {
        return MmkvUtils.get(TRANS_TO_CHINA_KEY, "英语")
    }

    private fun getTo(): String {
        return MmkvUtils.get(TRANS_TO_KEY, "en")
    }

    fun CToR(): Pair<String, String> {
        return getFrom() to getTo()
    }

    fun CToRCN(): Pair<String, String> {
        return getFromCN() to getToCN()
    }


}

object Scanning {
    private var scanning_from_CN = "中文"
    private var scanning_to_CN = "英语"

    private var scanning_from = "zh"
    private var scanning_to = "en"

    fun ScanFromToEnCn() = scanning_from_CN to scanning_to_CN
    fun ScanFromToEn() = scanning_from to scanning_to

    fun saveTo(toCN: String, to: String) {
        scanning_to_CN = toCN
        scanning_to = to
    }

    fun saveFrom(fromCN: String, from: String) {
        scanning_from_CN = fromCN
        scanning_from = from
    }
}

object VoiceLanguage {
    private var voice_from_CN = "中文"
    private var voice_to_CN = "英语"

    private var voice_from = "zh"
    private var voice_to = "en"

    fun VoiceFromToEnCn() = voice_from_CN to voice_to_CN
    fun VoiceFromToEn() = voice_from to voice_to

    fun saveTo(toCN: String, to: String) {
        voice_from_CN = toCN
        voice_from = to
    }

    fun saveFrom(fromCN: String, from: String) {
        voice_to_CN = fromCN
        voice_to = from
    }

}

private const val TRANS_FROM_CHINA_KEY = "TRANS_FROM_CHINA_KEY"

private const val TRANS_TO_CHINA_KEY = "TRANS_TO_CHINA_KEY"

private const val TRANS_FROM_KEY = "TRANS_FROM_KEY"

private const val TRANS_TO_KEY = "TRANS_TO_KEY"


object WenLanguage {

    private var wen_from_CN = "中文"
    private var wen_to_CN = "英语"

    private var wen_from = "zh"
    private var wen_to = "en"

    fun CFromR() = wen_from_CN to wen_to_CN

    fun CToR() = wen_from to wen_to

    fun saveTo(toCN: String, to: String) {
        wen_to_CN = toCN
        wen_to = to
    }

    fun saveFrom(fromCN: String, from: String) {
        wen_from_CN = fromCN
        wen_from = from
    }


}